﻿using QFramework;
using UnityEngine;

public class Player : QF_GameController
{
    public float aa;

    private void Start()
    {
        this.RegisterEvent<GameSaveEvent<Save2>>(e =>
        {
            e.data.aa = aa;
        })
        .UnRegisterWhenGameObjectDestroyed(gameObject);

        this.RegisterEvent<GameLoadEvent<Save2>>(e =>
        {
            aa = e.data.aa;
        })
        .UnRegisterWhenGameObjectDestroyed(gameObject);

        this.GetSystem<IUGUISystem>().ShowPanel<MainPanel>("_MainPanel", UILayer.Mid);

        this.RegisterEvent<PlayerDieEvent>(e =>
        {
            Debug.Log("玩家死亡");
        })
        .UnRegisterWhenGameObjectDestroyed(gameObject);
    }
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            // this.SendCommand(new ShootCommand(Vector2.left));
            // Debug.Log(this.SendCommand(new ShootCommand(Vector2.left)));
            // this.SendCommandFromPool<ShootCommand>();
            // this.SendParameterCommand<ShootCommand, Vector2>(Vector2.left,true);
            // this.SendCommand<ShootCommand, Vector2>(Vector2.left, true);
            // this.SendCommand<ShootCommand, TestShootData>(new TestShootData() { name = "a", dir = Vector2.left }, true);
        }
        if (Input.GetKeyDown(KeyCode.A))
        {
            this.GetSystem<IUGUISystem>().HidePanel<MainPanel>("_MainPanel", true);
        }
    }
}